﻿using AnQinFrameWorkAPI.Entity.Blog.DTO.BlogLogin;
using AnQinFrameWorkAPI.Service.Blog;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Blog;

/// <summary>
///     博客登录API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Blog")]
public class BlogLoginController : ControllerBase
{
    //业务服务接口
    private readonly BlogLoginService _blogLoginService;

    //构造注入
    public BlogLoginController(BlogLoginService blogLoginService)
    {
        _blogLoginService = blogLoginService;
    }

    /// <summary>
    ///     博客注册
    /// </summary>
    /// <param name="blogRegisterDTO"></param>
    [HttpPost("Register")]
    public async Task<IActionResult> BlogRegister([FromBody] BlogRegisterDTO blogRegisterDTO)
    {
        var response = await _blogLoginService.BlogRegister(blogRegisterDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     博客登录
    /// </summary>
    /// <param name="blogLoginDTO"></param>
    [HttpPost("Login")]
    public async Task<IActionResult> BlogRegister([FromBody] BlogLoginDTO blogLoginDTO)
    {
        var response = await _blogLoginService.BlogLogin(blogLoginDTO);
        return StatusCode(response.Status, response);
    }
}